public class AddTwoNumbers {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        ListNode virtualNode = new ListNode();
        ListNode last = virtualNode;
        int t = 0;
        while(l1 != null || l2 != null || t != 0) {
            if(l1 != null) {
                t += l1.val;
                l1 = l1.next;
            }
            if(l2 != null) {
                t += l2.val;
                l2 = l2.next;
            }

            // 尾插
            last.next = new ListNode(t % 10);
            last = last.next;
            t /= 10;
        }

        return virtualNode.next;
    }
}
